package cn.codeforfun.initialization.project;

import cn.codeforfun.initialization.server.model.Server;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author wangbin
 */
@Entity
@Table
@Getter
@Setter
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Project implements Serializable {

    private static final long serialVersionUID = 1988964628882141695L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
     * 项目名称
     */
    @Column(unique = true)
    private String name;

    private Date createAt = new Date();

    @ManyToMany
    @JoinTable(
            name = "project_server",
            joinColumns = @JoinColumn(name = "project_id"),
            inverseJoinColumns = @JoinColumn(name = "server_id")
    )
    private List<Server> serverList;
}
